#ifndef SMARTHOME_H
#define SMARTHOME_H
#include <QWidget>
#include <QTcpSocket>
#include <QtMqtt/qmqttclient.h>
#include <qdebug.h>
#include <QMessageBox>
#include <QJsonObject>
#include <QJsonDocument>
#include <QTimer>
namespace Ui {
class smarthome;
}
#define ON 1
#define OFF 0
#define LIVINGROOM 1
#define TOLETROOM 2
#define BEDROOM 3
#define KITCHENROOM 4
 struct light
{
  quint8 livingroom;
  quint8 toletroom;
  quint8 bedroom;
  quint8 kitchenroom;
  quint8 buzzer;
};

class smarthome : public QWidget
{
    Q_OBJECT

public:
    explicit smarthome(QString pid,QWidget *parent = nullptr);
    ~smarthome();
  private:
    void  mqtt_init();
private slots:
    void  connect_server_success();
    void   message_receive(const QByteArray &msg,const QMqttTopicName &topic);


    void on_livingroom_clicked();

    void on_toletroom_clicked();

    void on_bedroom_clicked();

    void on_kichenroom_clicked();

    void on_wuroom_clicked();

    void on_tabWidget_tabBarClicked(int index);

    void  uiinit();

    void timedeal();

    void on_timeEdit_editingFinished();

private:
    Ui::smarthome *ui;
    QString id;
    QMqttClient *client;
    struct light light;
    QTimer* time;
};

#endif // SMARTHOME_H
